<?php
require_once (APPLICATION_DIR."/application/model/Alumni_career.php");
class AlumniCareer
{
	function deleteCareer($p_intId)
	{
		$objCareer = new DataObjects_Alumni_career();
		$objCareer -> id = $p_intId;
		
		return $objCareer -> delete();
	}
	
	function getInfoCareer($p_intId)
	{
		$objCareer = new DataObjects_Alumni_career();
		/*$objCareer -> selectAdd();
		$objCareer -> selectAdd("alumni_career.*,
														location.id as location_id,
														industry.id as industry_id
														");
		$objCareer -> _join = " LEFT JOIN location ON alumni_career.location_id=location.id ";
		$objCareer -> _join .= " LEFT JOIN industry ON alumni_career.industry_id=industry.id ";
		
		$objCareer -> whereAdd("alumni_career.id=" . $p_intId);*/
		$objCareer -> whereAdd("id=" . $p_intId);
		$arrTmp = $objCareer -> fetchList();
		if ( count($arrTmp) )
			return $arrTmp[0];
		else
			return false;
	}
	
	function updateJob($p_arrInfo)
	{
		$objCareer = new DataObjects_Alumni_career();
		$objCareer -> position = $p_arrInfo["position"];
		$objCareer -> company = $p_arrInfo["company"];
		$objCareer -> address = $p_arrInfo["address"];
		$objCareer -> location_id = $p_arrInfo["location_id"];
		$objCareer -> industry_id = $p_arrInfo["industry_id"];
		$objCareer -> gender = $p_arrInfo["gender"];
		$objCareer -> age_from = $p_arrInfo["age_from"];
		$objCareer -> age_to = $p_arrInfo["age_to"];
		$objCareer -> salary_unit = $p_arrInfo["salary_unit"];
		if ( $p_arrInfo["salary_unit"] == "vn" || $p_arrInfo["salary_unit"] == "usd" )
			$objCareer -> salary = $p_arrInfo["salary"];
		$objCareer -> working_mode = $p_arrInfo["working_mode"];
		$objCareer -> experience_unit = $p_arrInfo["experience_unit"];
		if ( $p_arrInfo["experience_unit"] == 1 )
			$objCareer -> experience = $p_arrInfo["experience"];
		$objCareer -> description = $p_arrInfo["description"];	
		$objCareer -> expired = $p_arrInfo["expired"];	
		$objCareer -> status = $p_arrInfo["status"];	
		$objCareer -> whereAdd("id=" . $p_arrInfo["career_id"]);
		
		return $objCareer -> update(DB_DATAOBJECT_WHEREADD_ONLY);
	}
	
	function addJob($p_arrInfo)
	{
		$objCareer = new DataObjects_Alumni_career();
		$objCareer -> position = $p_arrInfo["position"];
		$objCareer -> company = $p_arrInfo["company"];
		$objCareer -> address = $p_arrInfo["address"];
		$objCareer -> location_id = $p_arrInfo["location_id"];
		$objCareer -> industry_id = $p_arrInfo["industry_id"];
		$objCareer -> gender = $p_arrInfo["gender"];
		$objCareer -> age_from = $p_arrInfo["age_from"];
		$objCareer -> age_to = $p_arrInfo["age_to"];
		$objCareer -> salary_unit = $p_arrInfo["salary_unit"];
		if ( $p_arrInfo["salary_unit"] == "vn" || $p_arrInfo["salary_unit"] == "usd" )
			$objCareer -> salary = $p_arrInfo["salary"];
		$objCareer -> working_mode = $p_arrInfo["working_mode"];
		$objCareer -> experience_unit = $p_arrInfo["experience_unit"];
		if ( $p_arrInfo["experience_unit"] == 1 )
			$objCareer -> experience = $p_arrInfo["experience"];
		$objCareer -> description = $p_arrInfo["description"];	
		$objCareer -> expired = $p_arrInfo["expired"];	
		$objCareer -> status = $p_arrInfo["status"];	
		$objCareer -> created = date("Y-m-d H:i:s");	
		
		return $objCareer -> insert();
	}
	
	function getListCareer($p_intStart, $p_intLimit)
	{
		$objCareer = new DataObjects_Alumni_career();
		$objCareer -> selectAdd();
		$objCareer -> selectAdd("alumni_career.*,
														location.location_name as location_name,
														industry.industry_name as industry_name
														");
		$objCareer -> _join = " LEFT JOIN location ON alumni_career.location_id=location.id ";
		$objCareer -> _join .= " LEFT JOIN industry ON alumni_career.industry_id=industry.id ";
		
		$objCareer -> orderBy("created DESC");
		$objCareer -> limit($p_intStart, $p_intLimit);
		$objCareer -> find();
		return $objCareer;
	}

	
}
?>